<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - SelectField Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<p class='demoTitle'>inputEx - SelectField Usage</p>


<!-- Example 1 -->
<div class='exampleDiv'>

	<p class="title">Basic SelectField creation</p>
	
	<p>Use the following code to create a basic inputEx SelectField.</p>

	<div class='demoContainer' id='container1'></div>

	<div class='codeContainer'>
		<form>
		<textarea name="code" class="JScript">
			new inputEx.SelectField({name: 'country', selectValues: ['United States of America','France'], parentEl: 'container1'});
		</textarea>
		</form>
	</div>

</div>



<!-- Example 2 -->
<div class='exampleDiv'>

	<p class="title">Updated event</p>
	
	<p>How to listen to the updated event :</p>

	<div class='demoContainer' id='container2'></div>

	<div class='codeContainer'>
		<form>
		<textarea name="code" class="JScript">
			var el = YAHOO.util.Dom.get('container2');
			var field = new YAHOO.inputEx.SelectField({name: 'country', selectValues: ['United States of America','France'], parentEl: el});
			var logDiv = YAHOO.inputEx.cn('div', null, null, "Log :<br />");
			el.appendChild(logDiv);
			field.updatedEvt.subscribe(function(e,params) {
				var value = params[0];
				logDiv.innerHTML += "Updated at "+(new Date())+" with value "+value+"<br />";
			});
		</textarea>
		</form>
	</div>

</div>


<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script> 

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/SelectField.js"  type='text/javascript'></script>

<script>

YAHOO.util.Event.addListener(window, 'load', function() {

	// Example 1
	new YAHOO.inputEx.SelectField({name: 'country', selectValues: ['United States of America','France'], parentEl: 'container1'});
	
	
	// Example 2
	var el = YAHOO.util.Dom.get('container2');
	var field = new YAHOO.inputEx.SelectField({name: 'country', selectValues: ['United States of America','France'], parentEl: el});

	var button1 = YAHOO.inputEx.cn('button', null, null, "SetValue with 'United States of America'");
	var val = 'United States of America';
	el.appendChild(button1);
	YAHOO.util.Event.addListener(button1, "click" ,function() {
	   field.setValue(val);
	   val = (val == 'France') ? 'United States of America' : 'France';
	   button1.innerHTML = "SetValue with '"+val+"'";
	});
	
	var logDiv = YAHOO.inputEx.cn('div', null, null, "Log :<br />");
	el.appendChild(logDiv);
	field.updatedEvt.subscribe(function(e,params) {
		var value = params[0];
		logDiv.innerHTML += "Updated at "+(new Date())+" with value "+value+"<br />";
	});
	
});

</script>

<script src="js/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code');
</script>

 </body>
</html>